/**
  ******************************************************************************
  * @file    gt32f030_rccclk.c
  * @author  GT Application Team
  * @version V1.0.0
  * @date    03-January-2025      
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2022 Giantec Semicondutor Inc</center></h2>
  *
  *             http://www.giantec-semi.com/
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/ 
#include "gt32f030.h"
#include "gt32f030_rccclko.h"

/** @addtogroup GT32F030_StdPeriph_Driver
  * @{
  */
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define RCC_CLKOCR_SOURCE_Pos            ((uint32_t)0x00000008)
#define RCC_CLKOCR_SOURCE_Msk            ((uint32_t)(0x7<<RCC_CLKOCR_SOURCE_Pos))
#define RCC_CLKOCR_CLKOEN_Msk            ((uint32_t)0x00001000)
#define RCC_CLKOCR_CLKOEN                ((uint32_t)0x00001000)


/** @defgroup RCCCLKO 
  * @brief RCCCLKO driver modules
  * @{
  */ 

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/** @defgroup RCCCLKO_Private_Functions
  * @{
  */ 

/** @defgroup RCCCLKO_Init Initialization functions
 *  @brief   Initialization and functions
 *
@verbatim    
 ===============================================================================
              ##### Initialization functions #####
 ===============================================================================
@endverbatim
  * @{
  */
/**
  * @brief  Initializes the RCC Clock output Function according to the specified
  *         parameters in the RCCCLKO_InitStruct .
  * @param  RCCCLKO_InitStruct: pointer to a RCCCLKO_InitTypeDef structure that contains
  *         the configuration information.
  * @retval None
  */
void RCCCLKO_Init(RCCCLKO_InitTypeDef* RCCCLKO_InitStruct)
{
	uint32_t tp1;
  /* Check the parameters */
  assert_param(IS_RCC_CLKOCLKSRC(RCCCLKO_InitStruct->RCCCLKO_Source));
//	assert_param(IS_RCC_CLKOHCLKDIV(RCCCLKO_InitStruct->RCCCLKO_HCLKDiv));
	
	tp1  = RCC->CLKOCR;
	tp1 &= ~RCC_CLKOCR_SOURCE_Msk;
	tp1 |= RCCCLKO_InitStruct->RCCCLKO_Source<<RCC_CLKOCR_SOURCE_Pos;
  
	RCC->CLKOCR = tp1;
}
/**
  * @}  
  */





/** @defgroup RCCCLKO_OpCfg Operation and Configuration functions
 *  @brief   Operation and Configuration functions
 *
@verbatim   
 ===============================================================================
           ##### Operation and Configuration functions #####
 ===============================================================================  
@endverbatim
  * @{
  */

/**
  * @brief  Enables or disables the RCC Clock output function.
  * @param  NewState: new state of the RCC Clock output.
  *         This parameter can be: ENABLE or DISABLE.
  * @retval None
  */
void RCCCLKO_Cmd(FunctionalState NewState)
{
  /* Check the parameters */
  assert_param(IS_FUNCTIONAL_STATE(NewState));

	if(NewState != DISABLE)
	{
		 RCC->CLKOCR |= RCC_CLKOCR_CLKOEN_Msk;
	}
	else
	{
		RCC->CLKOCR  &=~RCC_CLKOCR_CLKOEN_Msk;
	}
}
/**
  * @}  
  */ 

/**
  * @}  
  */

/**
  * @}  
  */ 

/**
  * @}
  */ 
/************************ (C) COPYRIGHT Giantec Semicondutor Inc *****END OF FILE****/
